<template>
    <view class="news-details">
		<view class="forbox" >
			<view class="title-box">
				<h1>{{list.systemnewstitle}}</h1>
				<view class="title-bottom">
					<p>{{list.systemnewspublicpeople}}</p>
					<p>{{list.systemnewstime}}</p>
				</view>
			</view>
			<view class="content">
				<p>{{list.systemnewscontent}}</p>
			</view>
		</view>
    </view>
</template>

<script>
    import resources from '@/libs/resources.js'
    import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
    import {
        getDictionaryDataSelector,
        getDataInterfaceRes
    } from '@/api/common'
    import request from '@/utils/request'
    export default {
		mixins: [MescrollMixin],
        data() {
            return {
                sortValue: '',
                searchForm: {
                    systemnewstitle:undefined,
                    systemnewscontent:undefined,
                    systemnewstime:undefined,
                    systemnewspublicpeople:undefined,
                },
                downOption: {
                    use: true,
                    auto: false
                },
                upOption: {
                    page: {
                        num: 0,
                        size: 20,
                        time: null,
                    },
                    empty: {
                        use: true,
                        icon: resources.message.nodata,
                        tip: "暂无数据",
                        fixed: true,
                        top: "300rpx",
                        zIndex: 5,
                    },
                    textNoMore: '没有更多数据',
                    toTop: {
                        bottom: 250
                    }
                },
				list: [
					{
						systemnewstitle:"今天下午入职培训会议今天下午入职培训会议",
						systemnewscontent:"入职培训，主要是公司对每一个初入公司的新员工介绍公司历史、基本工作流程、行为规范、组织结构、人员结构和处理同事关系等活动的总称，目的是使员工融入这个团队。入职培训，主要是公司对每一个初入公司的新员工介绍公司历史、基本工作流程、行为规范、组织结构、人员结构和处理同事关系等活动的总称，目的是使员工融入这个团队。入职培训，主要是公司对每一个初入公司的新员工介绍公司历史、基本工作流程、行为规范、组织结构、人员结构和处理同事关系等活动的总称，目的是使员工融入这个团队。",
						systemnewstime:"2022-10-07 11:22:00",
						systemnewspublicpeople:"系统公告",
					},
				],
				listQuery: {
				    sort: 'desc',
				    sidx: '',
				    keyword: '',
				    json: ''
				},
				options: [
                    {
                        text: '删除',
                        style: {
                            backgroundColor: '#dd524d'
                        }
                    },
				],
				sortOptions:[
				    {
				        label: '系统消息标题降序',
				        sidx: 'systemnewstitle',
				        value: 'systemnewstitledesc',
				        sort: 'desc'
				    },
				    {
				        label: '系统消息标题升序',
				        sidx: 'systemnewstitle',
				        value: 'systemnewstitleasc',
				        sort: 'asc'
				    },
				    {
				        label: '消息内容降序',
				        sidx: 'systemnewscontent',
				        value: 'systemnewscontentdesc',
				        sort: 'desc'
				    },
				    {
				        label: '消息内容升序',
				        sidx: 'systemnewscontent',
				        value: 'systemnewscontentasc',
				        sort: 'asc'
				    },
				    {
				        label: '发布时间降序',
				        sidx: 'systemnewstime',
				        value: 'systemnewstimedesc',
				        sort: 'desc'
				    },
				    {
				        label: '发布时间升序',
				        sidx: 'systemnewstime',
				        value: 'systemnewstimeasc',
				        sort: 'asc'
				    },
				    {
				        label: '发布方降序',
				        sidx: 'systemnewspublicpeople',
				        value: 'systemnewspublicpeopledesc',
				        sort: 'desc'
				    },
				    {
				        label: '发布方升序',
				        sidx: 'systemnewspublicpeople',
				        value: 'systemnewspublicpeopleasc',
				        sort: 'asc'
				    },
				],
                menuId:'',
				listid:''
            }
        },
        onLoad(e){
			this.listid=e.id
			this.menuId = e.menuId
            uni.$on('refresh', () => {
                this.list = [];
                this.mescroll.resetUpScroll();
            })
            this.dataAll()
			this.upCallback()
        },
        onUnload() {
            uni.$off('refresh')
        },
        methods:{
		
			
			dataAll(){
			},
			closeData(e){
			    if(e==1){
			        // this.reset()
			    }
			},
            upCallback(page) {
    //             for(let i in this.searchForm){
				// 	if(!this.searchForm[i]){
				// 		delete this.searchForm[i]
				// 	}
				// }
        
                request({
                    url: '/api/example/Mt_safe_system_news/detail/'+this.listid,
                    method: 'get',
                }).then(res => {
					this.list=res.data
					this.list.systemnewstime=this.timestampToTime(this.list.systemnewstime)
				console.log(res.data);
                }).catch(() => {
                  console.log('x');
                })
            },
			timestampToTime(timestamp) {
			       var  date = new Date(timestamp );//时间戳为10位需*1000，时间戳为13位的话不需乘1000
			       var Y = date.getFullYear() + '-';
			       var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
			       var D = date.getDate() + ' ';
			       return Y+M+D;
			   },
            handleClick(index, index1) {
				const item = this.list[index]
                request({
                    url: '/api/example/Mt_safe_system_news/' + item.id,
                    method: 'delete'
                }).then(res => {
                    uni.showToast({
                        title: res.msg,
                        complete: () => {
                            this.$u.toast(res.msg)
                            this.list.splice(index, 1)
							if (!this.list.length) this.mescroll.showEmpty()
                        }
                    })
                })
            },
            open(index) {
                this.list[index].show = true;
                this.list.map((val, idx) => {
                    if (index != idx) this.list[idx].show = false;
                })
            },
            search() {
                if (this.isPreview == '1') return
                this.searchTimer && clearTimeout(this.searchTimer)
                this.searchTimer = setTimeout(() => {
                    this.list = [];
                    this.mescroll.resetUpScroll();
                }, 300)
            },
            goDetail(id, status) {
                let btnType = ''
                let btnList = []
                btnList.push('btn_edit')
                btnList.push('btn_detail')
                if(btnList.includes('btn_detail')){
                    btnType = "btn_detail"
                }
                if(btnList.includes('btn_edit')){
                    btnType = "btn_edit"
                }
                if(!btnType) return
                this.jumPage(id, status,btnType)
            },
            addPage() {
				this.jumPage()
			},
            jumPage(id, status,btnType){
				if (!id && !status) btnType = 'btn_add'
				uni.navigateTo({
                    url: id?'./form?menuId='+this.menuId+'&jurisdictionType='+btnType+'&id=' + id:'./form?menuId='+this.menuId+'&jurisdictionType='+btnType
                })
			},
            cellClick(item) {
                if (this.sortValue === item.value) return
                this.listQuery.sort = item.sort
                this.listQuery.sidx = item.sidx
                this.sortValue = item.value
                this.$refs.uDropdown.close();
                this.$nextTick(() => {
                    this.list = [];
                    this.mescroll.resetUpScroll();
                })
            },
            reset() {
                this.$refs.searchForm.resetFields()
            },
            closeDropdown() {
                this.$refs.uDropdown.close();
                this.$nextTick(() => {
                    this.list = [];
                    this.mescroll.resetUpScroll();
                })
            },
			dataList(data){
				let _list =[]
				for(let i=0;i<data.list.length;i++){
					let _data = data.list[i]
					_list.push(_data)
				}
				return _list;
			},
        },
    }
</script>

<style lang="scss">
    page {
        background-color: #f0f2f6;
        height: 100%;
        /* #ifdef MP-ALIPAY */
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        /* #endif */
		.news-details{
			padding: 20rpx;
			.title-box{
				padding: 30rpx 30rpx;
				background-color: #fff;
				border-radius: 16rpx;
				margin-bottom: 20rpx;
				&>h1{
					font-size: 40rpx;
					font-weight: bold;
					margin-bottom: 20rpx;
					color: #333333;
				}
				.title-bottom{
					display: flex;
					justify-content: space-between;
					font-size: 30rpx;
					color: #797F85;
				}
			}
			.content{
				padding: 30rpx 30rpx;
				background-color: #fff;
				border-radius: 16rpx;
				margin-bottom: 20rpx;
				p{
					line-height: 1.6;
					font-size:32rpx;
					text-align:justify;
					color: #333333;
				}
			}
		}
    }
</style>
